package com.imooc.mall.model.util;


import com.imooc.mall.model.common.ApiRestResponse;
import com.imooc.mall.model.common.Constant;
import com.imooc.mall.model.exception.ImoocMallException;
import org.apache.tomcat.util.codec.binary.Base64;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

//md5工具
public class MD5Util {
    public static String getMD5Str(String strValue) throws NoSuchAlgorithmException {

            MessageDigest md5=MessageDigest.getInstance("MD5");
//        public static final String SALT="sdfjk234kui},?";
            return Base64.encodeBase64String(md5.digest((strValue+ Constant.SALT).getBytes()));

    }

    public static void main(String[] args) {
        String md5=null;
        try {
            md5=getMD5Str("1234");
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        Integer i=0;
        System.out.println(i);
        ApiRestResponse apiRestResponse=new ApiRestResponse();
        ImoocMallException exception=new ImoocMallException();
        System.out.println(exception);
        System.out.println(md5);
    }


}
